package com.gs.seckill.job;

import com.gs.common.core.redis.RedisCache;
import com.gs.gaosheng.domain.GsGoods;
import com.gs.seckill.mapper.SecKillMapper;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import org.springframework.scheduling.quartz.QuartzJobBean;

import javax.annotation.Resource;
import java.util.List;

public class SecKillPreHot extends QuartzJobBean {

  @Resource
  private SecKillMapper secKillMapper;

  @Resource
  private RedisCache redisCache;

  @Override
  protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
      List<GsGoods> stores = secKillMapper.findByStoreDesc();
      stores.forEach(u -> secKillMapper.updateGoodsStatus(u.getGoodsId()));
      redisCache.setCacheList("seckill",secKillMapper.findByStoreDesc());
  }
}
